<div class='fui-page fui-page-current' ng-if="pagedata.op=='main'">
	<div class="fui-header">
			<div class="fui-header-left" onclick="window.history.go(-1);">
				<a class="back"></a>
			</div>
			<div class="title">{{pagedata.post.id?'修改':'发布'}}{{pagedata.item_type.title}}</div>
			<div class="fui-header-right"></div>
	</div>
	<div class="fui-content">
	<!-- 关注按钮 -->
	<div class="fe-guide" ng-if="pagedata.isfollow==100" style="display:block;z-index:890;">
		<div class="fe-guide-faceimg"><img ng-src="{{tomedia(pagedata.pluginset.logo) || '../core/resource/images/nopic.jpg'}}" /></div>
		<div class="fe-guide-sub" onclick="$('#followbar').modal();">立即关注</div>
		<div class="fe-guide-text">
			<p class="">{{pagedata.pluginset.followtitle ||'加关注,更多权限！'}}</br>{{pagedata.pluginset.followdesc ||'关注公众号，享专属服务'}}</p>
		</div>
	</div>
	<div id="followbar" class="modal fade" tabindex="-1" style="z-index:99999;display:none;position: absolute">
		<div class="modal-dialog" style="width:60%;left:20%">
			<div class="wap-qrcode-container">
				<p class="example1">{{pagedata.pluginset.title || '欢迎浏览'}}</p>
					<div class="wap-qrcode-image">
						<img ng-src="{{tomedia(pagedata.pluginset.ewm) || '../core/resource/images/nopic.jpg'}}"/>
					</div>
				<p class="example1">长按二维码关注</p>
				</div>
		</div>
	</div>
	<div class="weui_cells weui_cells_form">
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">标题</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.title" value="{{pagedata.post.title}}" placeholder="请输入标题">
					</div>
				</div>
				<div ng-if="pagedata.post.type!=1" class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">公司名称</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.company_title" value="{{pagedata.post.company_title}}" placeholder="请输入公司名称">
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">岗位名称</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.company_jobname" value="{{pagedata.post.company_jobname}}" placeholder="请输入招聘岗位">
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">薪资待遇</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<select ng-model="pagedata.post.pay" class="form-control tpl-province">
								<option value="" selected="selected">选择薪资</option>
								<option ng-repeat="(key,value) in pagedata.pay" value="{{key}}" ng-selected="pagedata.post.pay==key;" >{{value}}</option>
						</select>
					</div>
				</div>
				<div  class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">地址</label></div>
					<div class="weui_cell" ng-init="pagedata.getlocation()">
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="pagedata.post.pcd.province" class="form-control tpl-province">
							<option value="" selected="selected">省份</option>
							<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.post.pcd.province==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="pagedata.post.pcd.city" class="form-control tpl-city">
							<option value="" selected="selected">城市</option>
							<option ng-repeat="(value,data) in pagedata.province[pagedata.post.pcd.province]" value="{{value}}" ng-selected="pagedata.post.pcd.city==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="pagedata.post.pcd.district" class="form-control tpl-district">
							<option value="" selected="selected">区县</option>
							<option ng-repeat="(value,data) in pagedata.province[pagedata.post.pcd.province][pagedata.post.pcd.city]" value="{{value}}" ng-selected="pagedata.post.pcd.district==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:28%">
							<select ng-model="pagedata.post.pcd.street" class="form-control tpl-district">
							<option value="" selected="selected">街道</option>
							<option ng-repeat="value in pagedata.province[pagedata.post.pcd.province][pagedata.post.pcd.city][pagedata.post.pcd.district]" value="{{value}}" ng-selected="pagedata.post.pcd.street==value">{{value}}</option>
							</select>
						</div>
					</div>
				</div>
				<div class="weui_cell">
						<input class="weui_input" type="text" ng-model="pagedata.post.address" placeholder="输入详细地址">
				</div>
			<div  class="weui_cell weui_vcode">
				<div class="weui_cell_hd"><label class="weui_label">选择坐标</label></div>
				<div class="weui_cell_bd weui_cell_primary col-xs-12 col-sm-8 col-lg-9">
						<div class="row row-fix">
							<div class="col-xs-4 col-sm-4">
								<input type="text" ng-model="pagedata.post.lat_lng.lng" placeholder="经度"  class="form-control" />
							</div>
							<div class="col-xs-4 col-sm-4">
								<input type="text" ng-model="pagedata.post.lat_lng.lat" placeholder="纬度"  class="form-control" />
							</div>
							<div class="col-xs-4 col-sm-4">
								<a ng-click="tool.choose_location(pagedata.post,'lat_lng','lat_lng')" class="btn btn-default btn-default-o btn-sm" type="button">选择坐标</a>
							</div>
						</div>
				</div>	
			</div>
				
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">联系人姓名</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.name" value="{{pagedata.post.name}}" placeholder="请输入联系人姓名">
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">联系人电话</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.mobile" value="{{pagedata.post.mobile}}" placeholder="请输入联系人电话">
					</div>
				</div>
				<div ng-if="pagedata.post.type==1" class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">您的年龄</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.age" value="{{pagedata.post.age}}" placeholder="请输入您的年龄">
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">学历</label></div>
					<div class="weui_cell_bd weui_cell_primary" style="width:33%">
								<select ng-model="pagedata.post.educationid" class="form-control tpl-province">
								<option value="" selected="selected">选择学历</option>
								<option ng-repeat="(key,value) in pagedata.educationid" value="{{key}}" ng-selected="pagedata.post.educationid==value">{{value}}</option>
								</select>
					</div>
				</div>
				<div ng-if="pagedata.post.type==1" class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">毕业院校</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="pagedata.post.school" value="{{pagedata.post.school}}" placeholder="请输入您的毕业院校">
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">{{pagedata.post.type!=1?'要求经验':'从事经验'}}</label></div>
					<div class="weui_cell_bd weui_cell_primary" style="width:33%">
								<select ng-model="pagedata.post.timesid" class="form-control tpl-province">
								<option value="" selected="selected">选择经验</option>
								<option ng-repeat="(key,value) in pagedata.timesid" value="{{key}}" ng-selected="pagedata.post.timesid==key">{{value}}</option>
								</select>
					</div>
				</div>
				<div class="weui_cell weui_vcode">
					<div class="weui_cell_hd"><label class="weui_label">{{pagedata.post.type!=1?'性别要求':'性别'}}</label></div>
					<div class="weui_cell_bd weui_cell_primary" style="width:33%">
								<select ng-model="pagedata.post.sex" class="form-control tpl-province">
								<option value="" selected="selected">选择性别</option>
								<option ng-repeat="(key,value) in pagedata.sex" value="{{key}}" ng-selected="pagedata.post.sex==key">{{value}}</option>
								</select>
					</div>
				</div>
	</div>
	<div class="weui_cells_title">说明</div>
	<div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea class="weui_textarea" ng-model="pagedata.post.remark" value="{{pagedata.post.remark}}" placeholder="请输入说明" rows="3"></textarea>
                    <div class="weui_textarea_counter">建议68个字以内！</div>
                </div>
            </div>
    </div>
	<div class="weui_cells_title">上传图片</div>
	<div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <div class="weui_uploader">
                        <div class="weui_uploader_bd">
                            <ul class="weui_uploader_files">
                                <li ng-repeat="p in pagedata.post.images" class="weui_uploader_file" style="background-image:url('{{tomedia(p)}}')">
									<div class="upbtn" >
										<a style="color:#f60" href="javascript:;" ng-click="pagedata.post.images.splice($index-1,0,p);pagedata.post.opus_images.splice($index+1,1)">上移</a>
										<a style="color:#f60" href="javascript:;" ng-click="pagedata.post.images.splice($index,1)">删除</a>
									</div>
								</li>
                            </ul>
                            <div class="weui_uploader_input_wrp" href="javascript:;" ng-click="images(pagedata.post,'images')"></div>
                        </div>
                    </div>
                </div>
            </div>
    </div>
	<div ng-repeat="item in pagedata.post.diyfileds">
			<div class="weui_cells weui_cells_form" ng-if="item.type == 1 || item.type == 9">
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">{{item.title}}<span ng-if="item.is_must" class="must"></span></label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" ng-model="item.data" placeholder="输入{{item.title}}内容">
                </div>
            </div>
			</div>
			<div class="weui_cells weui_cells_form" ng-if="item.type == 2">
			 <div class="weui_cell" ng-if="item.type == 2">
                <div class="weui_cell_hd"><label class="weui_label">{{item.title}}<span ng-if="item.is_must" class="must"></span></label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="number" ng-model="item.data" placeholder="输入{{item.title}}内容">
                </div>
            </div>
			</div>
			<div class="weui_cells weui_cells_form" ng-if="item.type == 3">
			<div class="weui_cell" ng-if="item.type == 3">
					<div class="weui_cell_hd"><label class="weui_label">{{item.title}}<span ng-if="item.is_must" class="must"></span></label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<ul class="weui_uploader_files" ng-if="item.data">
							  <li class="weui_uploader_file" style="background-image:url({{tomedia(item.data)}})"></li>
						</ul>
						<div class="weui_uploader_input_wrp">
							 <input class="weui_uploader_input" ng-click="up_file(item,'data','image')" accept="image/jpg,image/jpeg,image/png,image/gif" multiple="">
						</div>
					</div>
			</div>
			</div>
				<div ng-if="item.type == 4" class="weui_cells_title">{{item.title}}<span ng-if="item.is_must" class="must"></span></div>
				<div ng-if="item.type == 4" class="weui_cells weui_cells_radio2">
						<label class="weui_cell weui_check_label dashed" ng-repeat="(key,value) in item.value">

							<div class="weui_cell_bd weui_cell_primary">
								<span style="float:left;width:100%">{{value.title}}</span>
							</div>
							<div class="weui_cell_ft" href="javascript:;" ng-click="item.data=value.title;">
								<input type="radio" ng-checked="item.data==value.title" class="weui_check" name="radio1">
								<span class="weui_icon_checked"></span>
							</div>
						</label>
				</div>	
				<div ng-if="item.type == 5" class="weui_cells_title">{{item.title}}<span ng-if="item.is_must" class="must"></span></div>
				<div ng-if="item.type == 5" class="weui_cells weui_cells_checkbox" style="padding:0.5rem">
						<div class="fui-cell-label" style="margin-right:0.8rem;float:left;margin-bottom:0.2rem" ng-repeat="(key,value) in item.value">
							<input type="checkbox" ng-click="duoxuans(value.title,item,'data')" class="fui fui-checkbox fui-checkbox-danger verify-checkbox" ng-checked="item.data.indexOf(';'+value.title+';')>=0" id="s11"> {{value.title}}
						</div>
				</div>
				<div ng-if="item.type == 6" class="weui_cells_title">{{item.title}}<span ng-if="item.is_must" class="must"></span></div>
				<div ng-if="item.type == 6" class="weui_cells weui_cells_form">
				<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<textarea class="weui_textarea" ng-model="item.data" placeholder="请输入{{item.title}}" rows="2"></textarea>
							<div class="weui_textarea_counter"><span>0</span>/118</div>
						</div>
					</div>
				</div>
				<div ng-if="item.type == 7" class="weui_cells_title">{{item.title}}<span ng-if="item.is_must" class="must"></span></div>
				<div ng-if="item.type == 7" class="weui_cells weui_cells_form" ng-init="pagedata.getlocation()">
					<div class="weui_cell">
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="item.data.province" class="form-control tpl-province">
							<option value="" selected="selected">省份</option>
							<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="item.data.province==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="item.data.city" class="form-control tpl-city">
							<option value="" selected="selected">城市</option>
							<option ng-repeat="(value,data) in pagedata.province[item.data.province]" value="{{value}}" ng-selected="item.data.city==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:33%">
							<select ng-model="item.data.district" class="form-control tpl-district">
							<option value="" selected="selected">区县</option>
							<option ng-repeat="(value,data) in pagedata.province[item.data.province][item.data.city]" value="{{value}}" ng-selected="item.data.district==value">{{value}}</option>
							</select>
						</div>
						<div class="fui-cell-label" style="width:28%">
							<select ng-model="item.data.street" class="form-control tpl-district">
							<option value="" selected="selected">街道</option>
							<option ng-repeat="value in pagedata.province[item.data.province][item.data.city][item.data.district]" value="{{value}}" ng-selected="item.data.street==value">{{value}}</option>
							</select>
						</div>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" ng-model="item.data.xiangxi" placeholder="输入详细地址">
                </div>
				</div>
				<div class="weui_cells weui_cells_form" ng-if="item.type == 8 || item.type == 18">
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">{{item.title}}<span ng-if="item.is_must" class="must"></span></label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="number" ng-model="item.data" placeholder="输入{{item.title}}内容">
					</div>
				</div>
				</div>
				<div class="weui_cells weui_cells_form" style="padding:0;margin-top:0.3rem" ng-if="item.type == 10">
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary" style="padding:0;padding-bottom:0.3rem">
							<div class="weui_label" style="margin-bottom:0.3rem"><span>{{item.title}}</span></div>
							<div class="weui_uploader">
								<div class="weui_uploader_bd">
									<ul class="weui_uploader_files">
										<li ng-repeat="p in item.data track by $index" class="weui_uploader_file" style="background-image:url('{{tomedia(p)}}')">
											<div class="upbtn" >
												<i class="icon icon-shangyi" style="color:#f60" href="javascript:;" ng-click="item.data.splice($index-1,0,p);item.data.splice($index+1,1)"></i>
												<i class="icon icon-close" style="color:#f60" href="javascript:;" ng-click="item.data.splice($index,1)"></i>
											</div>
										</li>
									</ul>
									<div class="weui_uploader_input_wrp" href="javascript:;" ng-click="images(item,'data')">
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="weui_cells weui_cells_form" style="padding:0;margin-top:0.3rem" ng-if="item.type == 11">
					<div class="weui_cell">
							<div class="weui_cell_bd weui_cell_primary" style="">
								<div class="weui_label" style="margin-bottom:0.3rem"><span>{{item.title}}</span></div>
								<ul class="weui_uploader_files" ng-if="item.data">
									  <li class="weui_uploader_file" style="width: 108px;height: 60px;background: #333;">
										<video ng-src="{{tomedia(item.data)}}" poster="{{tomedia(item.thumb)}}" height="60" width="100%"  x5-playsinline="" playsinline="" webkit-playsinline="" preload="auto"></video>
									  </li>
								</ul>
								<div class="weui_uploader_input_wrp" ng-if="!item.data">
									 <input class="weui_uploader_input" ng-click="pagedata.up_file($index)"  multiple="">
								</div>
							</div>
					</div>
				</div>
				<div class="weui_cells weui_cells_form" ng-if="item.type == 13">
				<div class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">{{item.title}}<span ng-if="item.is_must" class="must"></span></label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_input" type="text" ng-model="item.data" placeholder="输入{{item.title}}">
					</div>
					<div class="weui_cell_ft" ng-click="tool.choose_location(item,'data','address')"><i class="icon jinyunicon icon-ditu"></i></div>
				</div>
				</div>
    </div>
	<div class="weui_btn_area">
			 <a class="weui_btn weui_btn_primary" href="javascript:" id="showTooltips" ng-click="pagedata.submit()">提交</a>
	</div>
</div>
</div>
<div ng-include="sys_html('_footer')"></div>
<script>
scope.pagedata.getlocation=function(index){
	if(scope.pagedata.os !='wxapp'){
		window.scope.location(function(re){
			scope.pagedata.post.pcd={};
				scope.pagedata.post.pcd.province = re.addressComponents.province
				scope.pagedata.post.pcd.city = re.addressComponents.city
				scope.pagedata.post.pcd.district = re.addressComponents.district
				scope.$evalAsync();
		});
	}
		
}
//提交
/*
scope.pagedata.submit=function(){
	var params={
		data:scope.pagedata.post,
		op:'main',
		callback:function(res){
			if(res.needfollow =='1'){
				scope.confirm({
					'message':'请先关注，再发布吧！',
					'success':function(){
						$('#followbar').modal();
					},
					'fail':function(){}
				});
			}
		}
	};
	scope.post_json(params);
}
*/
scope.pagedata.submit=function(){
	var str = /^[1][3,4,5,7,8][0-9]{9}$///手机
    var strname =  /^[\u4e00-\u9fa5]+(·[\u4e00-\u9fa5]+)*$/ //中文
    var stremail = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
	var filedata = scope.pagedata.post.diyfileds
	if(filedata){
		for (var i=0;i<filedata.length;i++){
			if(filedata[i].type ==8){
					if(!(str.test(filedata[i].data))){
					  scope.message("请输入正确的手机号码！",'error')
					}
			}
			if(filedata[i].type ==9){
					if(!(stremail.test(filedata[i].data))){
					  scope.message("请输入正确的邮箱！",'error')
					}
			}
		}
	}
	
	var params={
		data:scope.pagedata.post,
		op:'main',
		callback:function(res){
			if(res.payid){
				require(['tool'],function(tool){
					tool.pay(res.payid,function(res){
						if(res.type=='success'){
							scope.message('发布成功','','jy_aihire/myitem/main');
							
						}else{
							scope.message('支付失败！发布失败，失败原因：'+res.message,'error');
						}
					});
				});
			}
		}
	};
	scope.post_json(params);

}
scope.pagedata.getfileds = function(id){
		var params = {
					'plugin':'jy_vote',
					'action':'upopus',
					'op':'getfileds',
					'query':'id='+id,
					'data':{},
					'callback':function(data){
							//console.log(data)
							if(data.success == 1){
								scope.pagedata.post.fileds = data.post.fileds;
								scope.$evalAsync();
							}
					}
		}
		scope.post_json(params);
}
function showCoordinate(elm) {
						require(["util"], function(util){
							var val = {};
							if(window.scope.pagedata.post.lat_lng==undefined){
								window.scope.pagedata.post.lat_lng={};
							}
							val.lng = parseFloat(window.scope.pagedata.post.lat_lng.lng);
							val.lat = parseFloat(window.scope.pagedata.post.lat_lng.lat);
							util.map(val, function(r){
								window.scope.pagedata.post.lat_lng.lng=r.lng;
								window.scope.pagedata.post.lat_lng.lat=r.lat;
								window.scope.$apply();
							});

						});
}
scope.pagedata.up_file=function(index){
	scope.tool.up_file('video',function(video_url,image_url){
		//alert(image_url);
		scope.pagedata.post.diyfileds[index].data=video_url;
		scope.pagedata.post.diyfileds[index].thumb=image_url;
		scope.$evalAsync();
	});
}
</script>